package com.sline.Socket;

import java.io.IOException;
import java.net.*;

public class Demo1_Send {
    public static void main(String[] args) throws IOException {
        String str = "what are you 弄啥呢";
        // 创建socket
        DatagramSocket socket = new DatagramSocket();
        // 创建packet
        DatagramPacket packet = new DatagramPacket(str.getBytes(), str.getBytes().length, InetAddress.getByName("127.0.0.1"), 6666);
        // 将数据发出去
        socket.send(packet);
        // 关闭码头
        socket.close();
    }
}
